package com.itheima.flyweight;

/**
 * @author zzw
 * @date 2025/10/22
 * @description 享元模式测试类
 */
public class Client {
    public static void main(String[] args) {
        //享元工厂
        BoxFactory boxFactory = BoxFactory.getInstance();

        // 获取享元角色，AbstractBox为抽象享元角色
        AbstractBox i = boxFactory.getBox("I");
        AbstractBox l = boxFactory.getBox("L");
        AbstractBox o = boxFactory.getBox("O");

        // 获取非享元角色
        AbstractBox z = new ZBox();

        i.display("红色");
        l.display("绿色");
        o.display("蓝色");
        z.display("黄色");
    }
}
